import type { TreeDataType, TreeNodeType, TreeRawDataType } from "../type";
import type { CSSProperties } from "react";
import type { ReactNode } from "react";

export interface SideTreeProps {
  treeData: ((s?: string) => Promise<TreeDataType>) | TreeDataType;
  title?: string;
  total?: number;
  addChildText?: string;
  editable?: boolean;
  searchable?: boolean;
  checkable?: boolean;
  disabledCheckAll?: boolean;
  style?: CSSProperties;
  className?: string;
  defaultExpandAll?: boolean;
  maxShowDeepth?: number;
  maxCreateDeepth?: number;
  defaultSelected?: string | number; // 默认选中的节点
  selected?: string | number;
  checked?: Array<string | number>;
  defaultChecked?: Array<string | number>; // 默认选中复选框的树节点
  highlightSelected?: boolean;
  drawerTitle?: string; // 分组侧弹窗标题
  nodeTitleChangeValidator?: (text: string) => string | undefined;
  nodeTitleRender?: (i: TreeNodeType) => ReactNode;
  onSelect?: (key: string | number) => void;
  onChange?: (data: TreeRawDataType) => void;
  onNodeTitleChange?: TreeNodeTitleChange;
  onNodeRemove?: (key: string | number, treeData?: TreeDataType) => void;
  onNodeAdd?: TreeAddNode;
  onCheck?: (keys: Array<string | number>) => void;
  onRootNodeSelect?: () => void;
}

export type TreeNodeTitleChange = (
  key: string | number,
  title: string,
  treeData?: TreeDataType
) => void;

export type TreeAddNode = (
  parentKey: string | number | undefined,
  title: string,
  treeData?: TreeDataType
) => void;
